<template>
	<view>
		<u-search 
		:clearabled="true"  
		:show-action="true"
		 action-text="搜索" 
		 :animation="true" 
		 input-align="center" 
		 placeholder="输入你的问题吧"  
		height="70" 
		v-model="keyword"
		@change="getList"></u-search>
		<u-swipe-action 
			v-for="(item, index) in list" :key="item.id" 
		>
			<view class="item u-border-bottom" @click="open(item)">
				<image mode="aspectFill" :src="replaceURl(item.img)" />
				<view class="title-wrap">
					<text class="title u-line-2">{{ item.questTitle }}</text>
					<u-tag class="tagtitle" :text="item.questName" type="success" />
					<text class="timeTile">{{ item.time }}</text>
				</view>
				<!-- <view class=""><u-icon name="chat-fill" size="34" color="" label="30评论"></u-icon></view> -->
			</view>
		</u-swipe-action>
		<!-- 发贴入口 -->
		<add-post-tag></add-post-tag>
	</view>
</template>

<script>
	import addPostTag from '@/components/add-post-tag/add-reply-tag.vue';
	export default {
		components: {
			addPostTag
		},
		data() {
			return {
				keyword: '',
				list: [
				],
				visib:false,
				disabled: false,
				btnWidth: 180,
				show: false,
				options: [
					{
						text: '收藏',
						style: {
							backgroundColor: '#007aff'
						}
					},
					{
						text: '删除',
						style: {
							backgroundColor: '#dd524d'
						}
					}
				]
			};
		},
		onLoad() {
			this.getList();
		},
		methods: {
			getList() {
				this.$H.get('reply/list', {
					questTitle:this.keyword
				}).then(res => {
					if (res.code == 0) {
						this.list = res.page
					}
				})
			},
			click(index, index1) {

			},
			open(e) {
				let	url = '/pages/replys/post?id=' + e.id;
				uni.navigateTo({
					url: url
				});			
				},
			replaceURl(url){
				return url.replace(/^"|"$/g, '');
			}
		}
	};
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
		padding: 20rpx;
	}
	
	image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
		border-radius: 12rpx;
	}
	
	.title {
		text-align: left;
		font-size: 28rpx;
		color: $u-content-color;
		margin-top: 20rpx;
	}
	.timeTile{
		display: block;
		text-align: left;
		font-size: 25rpx;
	}
	.tagtitle{
		display: inline-block;
	}
	.u-card-wrap { 
			background-color: $u-bg-color;
			padding: 1px;
		}
	.u-body-item {
		font-size: 32rpx;
		color: #333;
		padding: 20rpx 10rpx;
	}
		
	.u-body-item image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		border-radius: 8rpx;
		margin-left: 12rpx;
	}
</style>